package com.example.test.mytestapplication.factorytest;

import android.util.Log;

import com.example.test.mytestapplication.factorytest.Bean.InfoBean;
import com.example.test.mytestapplication.factorytest.Utils.FileUtils;

/**
 * Created by cuige on 2018/10/28.
 */

public class FactoryTestManager {

    public static void checkVerison(int versionNow) {
        InfoBean infoBean = FileUtils.getStateFromFile();
        Log.i("更新版本前infoBean", infoBean+"");
        int versionBefore = infoBean.getVersionCode();
        if (versionNow > versionBefore) {
            //写入默认值
            InfoBean infoBeanNew = new InfoBean(Constants.TYPE_REQUEST_TEST, Constants.TYPE_REQUEST_TEST, versionNow, true);
            FileUtils.setStateToFile(infoBeanNew);
            infoBean = FileUtils.getStateFromFile();
            Log.i("更新版本后infoBean", infoBean+"");
        }
    }

    public static void setStateToFile(InfoBean infoBean){
        FileUtils.setStateToFile(infoBean);
    }

    public static String getIOTCloudUrl(){
        String IOTCloudUrl ;
        if(FileUtils.getStateFromFile().getIOTCloudCode() == 0){
            IOTCloudUrl = CloudServerUrl.BASE_IOT_URL_TEST;
        }else {
            IOTCloudUrl = CloudServerUrl.BASE_IOT_URL_API;
        }
        return IOTCloudUrl;
    }

    public static String getRecipesCloudUrl(){
        String recipesCloudUrl ;
        if(FileUtils.getStateFromFile().getIOTCloudCode() == 0){
            recipesCloudUrl = CloudServerUrl.BASE_RECIPES_URL_TEST;
        }else {
            recipesCloudUrl = CloudServerUrl.BASE_RECIPES_URL_API;
        }
        return recipesCloudUrl;
    }

}
